package com.me.jingdongshop.ui.activity;

import android.content.Intent;
import android.os.Message;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.me.common.base.BaseActivity;
import com.me.jingdongshop.R;
import com.me.jingdongshop.ui.view.CircleImageView;
import com.me.jingdongshop.ui.view.UserCenterItemView;

/**
 * Created by Administrator on 2017/5/5.
 * 【我的】模块：帐户中心详情页：包含账户中心和关于我们，通过visibility显示和隐藏切换
 */

public class AccountCenterActivity extends BaseActivity {

    private ImageView imgBack;
    private TextView tvTitle;
    private ImageView imgAddAccount;
    private CircleImageView circleHeadPortrait;
    private TextView tvName;
    private TextView tvLevel;
    private TextView tvIntegral;
    private UserCenterItemView usercenterItemIndent;
    private UserCenterItemView usercenterItemAddress;
    private UserCenterItemView usercenterItemPreferential;
    private UserCenterItemView usercenterItemCollection;
    private UserCenterItemView usercenterItemFeekback;
    private ImageButton imgAboutBack;
    private LinearLayout llDetail;
    private LinearLayout llAboutUs;

    @Override
    public int getLayoutRes() {
        return R.layout.my_account_center_details;
    }


    @Override
    public void initView() {

        //账户中心


        llDetail = (LinearLayout) findViewById(R.id.ll_detail);
        imgBack = (ImageView) findViewById(R.id.img_back);
        tvTitle = (TextView) findViewById(R.id.tv_title);
        imgAddAccount = (ImageView) findViewById(R.id.img_add_account);
        circleHeadPortrait = (CircleImageView) findViewById(R.id.circle_head_portrait);
        tvName = (TextView) findViewById(R.id.tv_name);
        tvLevel = (TextView) findViewById(R.id.tv_level);
        tvIntegral = (TextView) findViewById(R.id.tv_integral);
        usercenterItemIndent = (UserCenterItemView) findViewById(R.id.usercenter_item_indent);
        usercenterItemAddress = (UserCenterItemView) findViewById(R.id.usercenter_item_address);
        usercenterItemPreferential = (UserCenterItemView) findViewById(R.id.usercenter_item_preferential);
        usercenterItemCollection = (UserCenterItemView) findViewById(R.id.usercenter_item_collection);
        usercenterItemFeekback = (UserCenterItemView) findViewById(R.id.usercenter_item_feekback);

        //关于我们
        llAboutUs = (LinearLayout) findViewById(R.id.ll_about_us);
        imgAboutBack = (ImageButton) findViewById(R.id.img_about_back);

        usercenterItemAddress.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("我是地址------------------");
            }
        });

        initDefaultView();//默认显示/回显
        initItemClick();
//        帮助/反馈
        usercenterItemFeekback.setOnItemClickListener(new UserCenterItemView.onUserCenterItemClickListener() {
            @Override
            public void onUserCenterItemClick(View itemView) {
                showToast("不准投诉");
                Intent intent = new Intent(AccountCenterActivity.this, MyHelpCenterActicity.class);
                startActivity(intent);
            }
        });
//        我的订单
        usercenterItemIndent.setOnItemClickListener(new UserCenterItemView.onUserCenterItemClickListener() {
            @Override
            public void onUserCenterItemClick(View itemView) {
                showToast("我的订单");

            }
        });
//优惠券
        usercenterItemPreferential.setOnItemClickListener(new UserCenterItemView.onUserCenterItemClickListener() {
            @Override
            public void onUserCenterItemClick(View itemView) {
                showToast("优惠券");
                Intent coupon = new Intent(AccountCenterActivity.this,MyCouponActivity.class);
                startActivity(coupon);

            }
        });

    }

    /**
     * item点击
     */
    private void initItemClick() {

    }

    /**
     * 默认显示/回显
     */
    private void initDefaultView() {
        imgBack.setOnClickListener(this);
        imgAddAccount.setOnClickListener(this);





    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {
        //为自定义item设置数据-------
        //usercenterItemIndent本来就是一个UserCenterItemView对象，所以可以调用UserCenterItemView里面的方法
        usercenterItemIndent.setUsercenterItemNameText("我的订单(999)");


    }


    @Override
    public void onClick(View v, int id) {

        switch (id) {
//            账户中心
            case R.id.img_back:
                showToast("返回上一层");
                finish();
                break;
            case R.id.img_add_account:
                showToast("关于我们");
                llDetail.setVisibility(View.GONE);
                llAboutUs.setVisibility(View.VISIBLE);
                break;
            //关于我们
            case R.id.img_about_back:
                showToast("返回帐号中心");
                llDetail.setVisibility(View.VISIBLE);
                llAboutUs.setVisibility(View.GONE);
                break;

        }


    }

    @Override
    public void onHttpSuccess(int reqType, Message msg) {

    }

    @Override
    public void onHttpError(int reqType, String error) {

    }


}
